import {get,post} from '../utils/request';
const API_URL = 'https://test.youbaobao.xyz:18081/';

export function getAllHomeData(params) {  //首页数据
  return get(`${API_URL}book/home/v2?`,params);
}

export function getRecommend() {
  return get(`${API_URL}book/home/recommend/v2`);
}

export function getFreeRead() {
  return get(`${API_URL}book/home/freeRead/v2`);
}

export function getHotBook() {
  return get(`${API_URL}book/home/hotBook/v2`);
}

export function getOpenId(code) {
  return get(`${API_URL}openId/get`,{
    appId : 'wx96d887ff064843a5',//wx6ca257b141a31ade
    secret :'8bdbcdf6f7e47b56be6dcf31fdd7f2ea',//a32f84636cfcdba9688f928da3e2cbb4
    code
  });
}

export function register(openId,userInfo) {  //注册用户信息
    return post(`${API_URL}user/register`,{
      openId,
      platform:mpvuePlatform,
      ...userInfo,
    })
}

export function search(params) {
  return get(`${API_URL}book/search`,params);
}

export function hotSearch() {
  return get(`${API_URL}book/hot-search`);
}

export function bookDetail(params) {
  return get(`${API_URL}book/detail`,params);
}

export function rank(params) {
  return get(`${API_URL}book/rank/save`,params);
}

export function bookContents(params) {
  return get(`${API_URL}book/contents`,params);
}

export function bookShelfState(params) {
  return get(`${API_URL}book/shelf/get`,params);
}

export function joinShelf(params) {
  return get(`${API_URL}book/shelf/save`,{
    shelf : JSON.stringify(params),
  });
}

export function removeShelf(params) {
  return get(`${API_URL}book/shelf/remove`,{
    shelf : JSON.stringify(params),
  });
}

export function searchCategoryList(params,value,page) {
  return get(`${API_URL}book/search-list?${params}=${value}&page=${page}`);
}

export function getAllCategory() {
  return get(`${API_URL}book/category/list/v2`);
}

export function getShelfList(params) {
  return get(`${API_URL}book/shelf/get`,params);
}

export function getUserDay(params) {
  return get(`${API_URL}user/day`,params);
}
